/**
 * 
 */
$(document).ready(function(){
	var token = $.zui.store.get("token");
	var userId = $.zui.store.get("userId");
	console.log("token="+token+",userId="+userId);
	if (token!='' && typeof(token)!="undefined"
		&& userId!='' && typeof(userId)!="undefined"){
	
		location.href='admin/admin.jsp';
	}
	
	$("#loginBtn").click(function(){
		if($("#userName").val()==""){
			$('#userName').tooltip('show', '请输入用户名');
			return;
		}
		if($("#upwd").val()==""){
			$('#upwd').tooltip('show', '请输入密码');
			return;
		}
		
		var loginUrl=adminQueryUrl+adminUserService+"/login.action";
		alert(loginUrl);
		
		var param="";
		param +="&username="+$("#userName").val();
		param +="&upwd="+$("#upwd").val();
		alert(param);
		$.get(loginUrl,param,function(data,status){
			
			var jsonobj=jQuery.parseJSON(data);
			if(jsonobj.success=="1"){
				$.zui.store.set("userName", jsonobj.username);
				$.zui.store.set("userId", jsonobj.userId);
				$.zui.store.set("token", jsonobj.token);
				$.zui.store.set("trueName", jsonobj.trueName);	
				location.href = "admin/admin.jsp";
			}
			else {
				new $.zui.Messager('用户名或者密码错', {
				    type: 'warning',
				    placement:'center'
				}).show();
				$("#loginBtn").button('reset');
			}
		},"text");
/*		$.ajax({
		
			url:loginUrl,
			type:'post',
//			data:param,
			dataType:'JSON',
			success:function(result){
				if (result.success == '1'){
					$.zui.store.set('token', result.token);  
					$.zui.store.set('userId', result.userId);  
					$.zui.store.set('userName', result.userName);      
					$.zui.store.set('headpic', result.headpic);  
					location.href = "admin/admin.jsp";
				}
				else{
					new $.zui.Messager('用户名或者密码错误!', {
					    type: 'warning', // 定义颜色主题
					    placement: 'center' // 定义显示位置
					}).show();
				}
//           if(result=='1'){
//        	 alert("登录成功");
//           }
//           else{
//        	   new $.zui.Messager('用户名或密码错误', {
//				    type: 'danger' // 定义颜色主题
//				}).show();
//           }
			},
			error:function(result){
				  new $.zui.Messager('系统繁忙，请稍后再试', {
					    type: 'danger' // 定义颜色主题
					}).show();
			}
			
		});
		*/
		
		
		
		
		
	});
	
	
	
	
	
});